package laplacianGrowthUtils;

public class Grid2DPotential {
	protected int x,y; 
	protected double potential;
	public double getPotential() {
		return potential;
	}
	public void setPotential(double potential) {
		this.potential = potential;
	}
	public int getX() {
		return x;
	}
	public int getY() {
		return y;
	}
	public Grid2DPotential(int x, int y, double potential) {
		super();
		this.x = x;
		this.y = y;
		this.potential = potential;
	}
	public Grid2DPotential(int x, int y) {
		super();
		this.x = x;
		this.y = y;
	} 
	
	public int hashCode(){
		return (x+y)%23; 
	}
	public boolean equals(Object o){
		if(!(o instanceof Grid2DPotential)) return false; 
		Grid2DPotential go=(Grid2DPotential)o; 
		return ((x==go.x)&&(y==go.y)); 
	}
		
	public static double distance(Grid2DPotential a,Grid2DPotential b){
		return Math.sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); 
	}
	public String toString(){
		String s="("+x+","+y+","+potential+")";
		return s; 
	}
}
